<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->

<!-- Mirrored from minetest.gitlab.io/minetest/tools/ by HTTrack Website Copier/3.x [XR&CO'2014], Thu, 01 Oct 2020 14:46:27 GMT -->
<!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=utf-8" /><!-- /Added by HTTrack -->
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  
  
  <link rel="shortcut icon" href="../img/favicon.ico">
  <title>Tools - Minetest API Documentation</title>
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato:400,700|Roboto+Slab:400,700|Inconsolata:400,700" />

  <link rel="stylesheet" href="../css/theme.css" />
  <link rel="stylesheet" href="../css/theme_extra.css" />
  <link href="../css/code_styles.css" rel="stylesheet" />
  <link href="../css/extra.css" rel="stylesheet" />
  
  <script>
    // Current page data
    var mkdocs_page_name = "Tools";
    var mkdocs_page_input_path = "tools.md";
    var mkdocs_page_url = null;
  </script>
  
  <script src="../js/jquery-2.1.1.min.js" defer></script>
  <script src="../js/modernizr-2.8.3.min.js" defer></script> 
  
</head>

<body class="wy-body-for-nav" role="document">

  <div class="wy-grid-for-nav">

    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side stickynav">
    <div class="wy-side-scroll">
      <div class="wy-side-nav-search">
        <a href="../index.html" class="icon icon-home"> Minetest API Documentation</a>
        <div role="search">
  <form id ="rtd-search-form" class="wy-form" action="http://minetest.gitlab.io/minetest/search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" title="Type search term here" />
  </form>
</div>
      </div>

      <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../index.html">Home</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../games/index.html">Games</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../mods/index.html">Mods</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../aliases/index.html">Aliases</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../textures/index.html">Textures</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../sounds/index.html">Sounds</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../registered-definitions/index.html">Registered definitions</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../nodes/index.html">Nodes</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../map-terminology-and-coordinates/index.html">Map terminology and coordinates</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../hud/index.html">HUD</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../representations-of-simple-things/index.html">Representations of simple things</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../flag-specifier-format/index.html">Flag Specifier Format</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../items/index.html">Items</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../groups/index.html">Groups</a>
                    </li>
                </ul>
                <ul class="current">
                    <li class="toctree-l1 current"><a class="reference internal current" href="index.html">Tools</a>
    <ul class="current">
    <li class="toctree-l2"><a class="reference internal" href="#tools-definition">Tools definition</a>
        <ul>
    <li class="toctree-l3"><a class="reference internal" href="#full-punch-interval">Full punch interval</a>
    </li>
    <li class="toctree-l3"><a class="reference internal" href="#maximum-drop-level">Maximum drop level</a>
    </li>
    <li class="toctree-l3"><a class="reference internal" href="#uses">Uses</a>
    </li>
    <li class="toctree-l3"><a class="reference internal" href="#maximum-level">Maximum level</a>
    </li>
    <li class="toctree-l3"><a class="reference internal" href="#digging-times">Digging times</a>
    </li>
    <li class="toctree-l3"><a class="reference internal" href="#damage-groups">Damage groups</a>
    </li>
        </ul>
    </li>
    <li class="toctree-l2"><a class="reference internal" href="#example-definition-of-the-capabilities-of-a-tool">Example definition of the capabilities of a tool</a>
    </li>
    </ul>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../entity-damage-mechanism/index.html">Entity damage mechanism</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../metadata/index.html">Metadata</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../formspec/index.html">Formspec</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../inventory/index.html">Inventory</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../colors/index.html">Colors</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../escape-sequences/index.html">Escape sequences</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../spatial-vectors/index.html">Spatial Vectors</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../helper-functions/index.html">Helper functions</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../translations/index.html">Translations</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../perlin-noise/index.html">Perlin noise</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../ores/index.html">Ores</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../decoration-types/index.html">Decoration types</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../schematics/index.html">Schematics</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../lua-voxel-manipulator/index.html">Lua Voxel Manipulator</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../mapgen-objects/index.html">Mapgen objects</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../registered-entities/index.html">Registered entities</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../l-system-trees/index.html">L-system trees</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../minetest-namespace-reference/index.html">'minetest' namespace reference</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../class-reference/index.html">Class reference</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../definition-tables/index.html">Definition tables</a>
                    </li>
                </ul>
      </div>
    </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" role="navigation" aria-label="top navigation">
        <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
        <a href="../index.html">Minetest API Documentation</a>
      </nav>

      
      <div class="wy-nav-content">
        <div class="rst-content">
          <div role="navigation" aria-label="breadcrumbs navigation">
  <ul class="wy-breadcrumbs">
    <li><a href="../index.html">Docs</a> &raquo;</li>
    
      
    
    <li>Tools</li>
    <li class="wy-breadcrumbs-aside">
      
    </li>
  </ul>
  
  <hr/>
</div>
          <div role="main">
            <div class="section">
              
                <h1 id="tools">Tools<a class="headerlink" href="#tools" title="Permanent link">&para;</a></h1>
<h2 id="tools-definition">Tools definition<a class="headerlink" href="#tools-definition" title="Permanent link">&para;</a></h2>
<p>Tools define:</p>
<ul>
<li>Full punch interval</li>
<li>Maximum drop level</li>
<li>For an arbitrary list of groups:<ul>
<li>Uses (until the tool breaks)<ul>
<li>Maximum level (usually <code>0</code>, <code>1</code>, <code>2</code> or <code>3</code>)</li>
<li>Digging times</li>
<li>Damage groups</li>
</ul>
</li>
</ul>
</li>
</ul>
<h3 id="full-punch-interval">Full punch interval<a class="headerlink" href="#full-punch-interval" title="Permanent link">&para;</a></h3>
<p>When used as a weapon, the tool will do full damage if this time is spent
between punches. If e.g. half the time is spent, the tool will do half
damage.</p>
<h3 id="maximum-drop-level">Maximum drop level<a class="headerlink" href="#maximum-drop-level" title="Permanent link">&para;</a></h3>
<p>Suggests the maximum level of node, when dug with the tool, that will drop
it's useful item. (e.g. iron ore to drop a lump of iron).</p>
<p>This is not automated; it is the responsibility of the node definition
to implement this.</p>
<h3 id="uses">Uses<a class="headerlink" href="#uses" title="Permanent link">&para;</a></h3>
<p>Determines how many uses the tool has when it is used for digging a node,
of this group, of the maximum level. For lower leveled nodes, the use count
is multiplied by <code>3^leveldiff</code>.
<code>leveldiff</code> is the difference of the tool's <code>maxlevel</code> <code>groupcaps</code> and the
node's <code>level</code> group. The node cannot be dug if <code>leveldiff</code> is less than zero.</p>
<ul>
<li><code>uses=10, leveldiff=0</code>: actual uses: 10</li>
<li><code>uses=10, leveldiff=1</code>: actual uses: 30</li>
<li><code>uses=10, leveldiff=2</code>: actual uses: 90</li>
</ul>
<h3 id="maximum-level">Maximum level<a class="headerlink" href="#maximum-level" title="Permanent link">&para;</a></h3>
<p>Tells what is the maximum level of a node of this group that the tool will
be able to dig.</p>
<h3 id="digging-times">Digging times<a class="headerlink" href="#digging-times" title="Permanent link">&para;</a></h3>
<p>List of digging times for different ratings of the group, for nodes of the
maximum level.</p>
<p>For example, as a Lua table, <code>times={2=2.00, 3=0.70}</code>. This would
result in the tool to be able to dig nodes that have a rating of <code>2</code> or <code>3</code>
for this group, and unable to dig the rating <code>1</code>, which is the toughest.
Unless there is a matching group that enables digging otherwise.</p>
<p>If the result digging time is 0, a delay of 0.15 seconds is added between
digging nodes; If the player releases LMB after digging, this delay is set to 0,
i.e. players can more quickly click the nodes away instead of holding LMB.</p>
<h3 id="damage-groups">Damage groups<a class="headerlink" href="#damage-groups" title="Permanent link">&para;</a></h3>
<p>List of damage for groups of entities. See [Entity damage mechanism].</p>
<h2 id="example-definition-of-the-capabilities-of-a-tool">Example definition of the capabilities of a tool<a class="headerlink" href="#example-definition-of-the-capabilities-of-a-tool" title="Permanent link">&para;</a></h2>
<div class="codehilite"><pre><span></span><code><span class="n">tool_capabilities</span> <span class="o">=</span> <span class="p">{</span>
    <span class="n">full_punch_interval</span><span class="o">=</span><span class="mf">1.5</span><span class="p">,</span>
    <span class="n">max_drop_level</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span>
    <span class="n">groupcaps</span><span class="o">=</span><span class="p">{</span>
        <span class="n">crumbly</span><span class="o">=</span><span class="p">{</span><span class="n">maxlevel</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">uses</span><span class="o">=</span><span class="mi">20</span><span class="p">,</span> <span class="n">times</span><span class="o">=</span><span class="p">{[</span><span class="mi">1</span><span class="p">]</span><span class="o">=</span><span class="mf">1.60</span><span class="p">,</span> <span class="p">[</span><span class="mi">2</span><span class="p">]</span><span class="o">=</span><span class="mf">1.20</span><span class="p">,</span> <span class="p">[</span><span class="mi">3</span><span class="p">]</span><span class="o">=</span><span class="mf">0.80</span><span class="p">}}</span>
    <span class="p">}</span>
    <span class="n">damage_groups</span> <span class="o">=</span> <span class="p">{</span><span class="n">fleshy</span><span class="o">=</span><span class="mi">2</span><span class="p">},</span>
<span class="p">}</span>
</code></pre></div>

<p>This makes the tool be able to dig nodes that fulfil both of these:</p>
<ul>
<li>Have the <code>crumbly</code> group</li>
<li>Have a <code>level</code> group less or equal to <code>2</code></li>
</ul>
<p>Table of resulting digging times:</p>
<div class="codehilite"><pre><span></span><code><span class="n">crumbly</span>        <span class="m">0</span>     <span class="m">1</span>     <span class="m">2</span>     <span class="m">3</span>     <span class="m">4</span>  <span class="o">&lt;-</span> <span class="n">level</span>
     <span class="o">-&gt;</span>  <span class="m">0</span>     <span class="o">-</span>     <span class="o">-</span>     <span class="o">-</span>     <span class="o">-</span>     <span class="o">-</span>
         <span class="m">1</span>  <span class="m">0.80</span>  <span class="m">1.60</span>  <span class="m">1.60</span>     <span class="o">-</span>     <span class="o">-</span>
         <span class="m">2</span>  <span class="m">0.60</span>  <span class="m">1.20</span>  <span class="m">1.20</span>     <span class="o">-</span>     <span class="o">-</span>
         <span class="m">3</span>  <span class="m">0.40</span>  <span class="m">0.80</span>  <span class="m">0.80</span>     <span class="o">-</span>     <span class="o">-</span>

<span class="n">level</span> <span class="n">diff</span><span class="o">:</span>    <span class="m">2</span>     <span class="m">1</span>     <span class="m">0</span>    <span class="m">-1</span>    <span class="m">-2</span>
</code></pre></div>

<p>Table of resulting tool uses:</p>
<div class="codehilite"><pre><span></span><code><span class="err">-&gt;  0     -     -     -     -     -</span>
<span class="err">    1   180    60    20     -     -</span>
<span class="err">    2   180    60    20     -     -</span>
<span class="err">    3   180    60    20     -     -</span>
</code></pre></div>

<p><strong>Notes</strong>:</p>
<ul>
<li>At <code>crumbly==0</code>, the node is not diggable.</li>
<li>At <code>crumbly==3</code>, the level difference digging time divider kicks in and makes
  easy nodes to be quickly breakable.</li>
<li>At <code>level &gt; 2</code>, the node is not diggable, because it's <code>level &gt; maxlevel</code></li>
</ul>
              
            </div>
          </div>
          <footer>
  
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="../entity-damage-mechanism/index.html" class="btn btn-neutral float-right" title="Entity damage mechanism">Next <span class="icon icon-circle-arrow-right"></span></a>
      
      
        <a href="../groups/index.html" class="btn btn-neutral" title="Groups"><span class="icon icon-circle-arrow-left"></span> Previous</a>
      
    </div>
  

  <hr/>

  <div role="contentinfo">
    <!-- Copyright etc -->
    
  </div>

  Built with <a href="https://www.mkdocs.org/">MkDocs</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org/">Read the Docs</a>.
</footer>
      
        </div>
      </div>

    </section>

  </div>

  <div class="rst-versions" role="note" aria-label="versions">
    <span class="rst-current-version" data-toggle="rst-current-version">
      
      
        <span><a href="../groups/index.html" style="color: #fcfcfc;">&laquo; Previous</a></span>
      
      
        <span style="margin-left: 15px"><a href="../entity-damage-mechanism/index.html" style="color: #fcfcfc">Next &raquo;</a></span>
      
    </span>
</div>
    <script>var base_url = '../index.html';</script>
    <script src="../js/theme.js" defer></script>
      <script src="../search/main.js" defer></script>
    <script defer>
        window.onload = function () {
            SphinxRtdTheme.Navigation.enable(true);
        };
    </script>

</body>

<!-- Mirrored from minetest.gitlab.io/minetest/tools/ by HTTrack Website Copier/3.x [XR&CO'2014], Thu, 01 Oct 2020 14:46:27 GMT -->
</html>
